<!DOCTYPE html>
<html class="bg-white" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<link rel="stylesheet" th:href="@{/css/admin.css}" media="all" />
<body>
<form id="postForm" lay-filter="postForm" class="layui-form model-form">
    <input name="configId" type="hidden"/> <!--岗位序号-->
    <div class="layui-form-item">
        <label class="layui-form-label">参数名称</label>
        <div class="layui-input-block">
            <input name="configName" placeholder="请输入参数名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">参数键名</label>
        <div class="layui-input-block">
            <input name="configKey" placeholder="请输入参数键名" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">参数键值</label>
        <div class="layui-input-block">
            <input name="configValue" placeholder="请输入参数键值" type="text" class="layui-input" lay-verify=""
                   required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">系统内置</label>
        <div class="layui-input-block">
            <input type="radio" name="configType" value="Y" title="是" checked/>
            <input type="radio" name="configType" value="N" title="否"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" placeholder="请输入内容" class="layui-textarea" maxlength="200"></textarea>
        </div>
    </div>

    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="btnSubmit" lay-submit>保存</button>
    </div>
</form>

<!-- js部分 -->
<div th:include="include::footer"></div>
<script type="text/javascript" th:src="@{/js/common.js}"></script>

<script>
    layui.use(['layer', 'form','admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;

        var url = ctx+"system/config/add";
        // 回显数据
        var post = admin.getTempData('t_post');
        if(post){
            form.val('postForm', post);
            url = ctx+"system/config/edit";
        }

        //监听指定开关
        /*     form.on('switch(switchTest)', function (data) {
                 if (this.checked) {
                     $("#status").val(0); //启用
                 }
                 else {
                     $("#status").val(1);//停用
                 }
             });*/

        // 表单提交事件
        form.on('submit(btnSubmit)', function (data) {
            layer.load(2);
            console.log(url);
            $.post(url, data.field, function (data) {
                layer.closeAll('loading');
                if (data.code == 0) {
                    top.layer.msg(data.msg, {icon: 1});
                    admin.putTempData('formOk', true);  // 操作成功刷新表格
                    // 关闭当前iframe弹出层
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                } else {
                    top.layer.msg(data.msg, {icon: 2});
                }
            });
            return false;
        });



    });
</script>
</body>
</html>